package cn.com.dhc.danlu.activity.envelope;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

import cn.com.dhc.danlu.R;
import cn.com.dhc.danlu.widget.dialog.ViewDialog;

/**
 * @description 该界面为红包说明和活动规则界面
 */
public class InstructionAndRuleActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_instructions);
        findViewById(R.id.ll_service).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                callPhoneAlert();
            }
        });
    }

    protected void callPhoneAlert() {
        new ViewDialog.Builder(this).setMessage("400-011-6666")
                .setNegativeButton(R.string.btn_cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                })
                .setPositiveButton(R.string.btn_confirm, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        call();
                        dialog.dismiss();
                    }
                }).create().show();

    }

    protected void call() {
        String phone = "400-011-6666";
        // 这里"tel:"+电话号码 是固定格式，系统一看是以"tel:"开头的，就知道后面应该是电话号码。
        Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone.trim()));
        startActivity(intent);// 调用上面这个intent实现拨号
    }
}